﻿@model PagedList.IPagedList<SoftHotel.Models.Cliente>

@{
    ViewBag.Title = "Clientes";
}

<h2>Clientes</h2>

<fieldset>
<legend>Búsqueda de Clientes</legend>


@using (Html.BeginForm())
{
    <p>
        Buscar por nombre: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string)  
        <input type="submit" value="Buscar" /></p>
}

<br />

<table rules="all" style="border-color: #bgbgbg; width: 900px; margin-bottom: 0px;" border="1">
    <tr>    
       
        <th style="font-weight: bold; width: 50px;" align="center">
            Número de Documento
        </th>
       
        <th style="font-weight: bold; width: 150px;" align="center">
            Nombres
        </th>
        <th style="font-weight: bold; width: 150px;" align="center">
           Apellido Paterno </th>
        <th style="font-weight: bold; width: 150px;" align="center">
            Apellido Materno
        </th>
        
        <th style="font-weight: bold; width: 100px;" align="center">
            Tipo de Documento
        </th>
        
        <th style="font-weight: bold; width: 100px;" align="center">
            Tipo Cliente
        </th>
        
      
    </tr>
    @foreach (var genre in Model)
    {
              
    <tr style="color:@(genre.apellidoPaterno == "carlos" ? "red" : "black")">     
            
       <td align="center"> 
       @using (Ajax.BeginForm("BuscarCliente", "ReservaEv",
       null
        , new AjaxOptions
        {
            UpdateTargetId = "update-message",
            InsertionMode = InsertionMode.Replace,
            HttpMethod = "POST",
            OnSuccess = "searchSuccess"
        }, new { @id = "searchForm"+@genre.idCliente }))
       {
    
    <div id="update-message" class="error invisible"></div>
        <input data-val="true"  data-val-number="The field idCliente must be a number." data-val-required="El campo idCliente es obligatorio." id="idCliente" name="idCliente" type="hidden" value="@genre.idCliente" />   
        @Html.HiddenFor(model => genre.idCliente,new {id="idCliente"+@genre.idCliente })
           @Html.HiddenFor(model => genre.nombres, new { id = "nombres" + @genre.idCliente }) 
             @Html.HiddenFor(model => genre.numDoc, new { id = "numDoc" + @genre.idCliente }) 
             @Html.HiddenFor(model => genre.objeTipoDoc.valor, new { id = "tipoDoc" + @genre.idCliente }) 
          
           
           <input type="submit" value="@genre.numDoc" />
       } 
        

        </td>
        <td align="center"> 
            @genre.nombres
        </td>
        <td align="center">
            @genre.apellidoPaterno
        </td>
        <td align="center"> 
            @genre.apellidoMaterno
        </td>       
       
        <td align="center"> 
            @genre.objeTipoDoc.valor
        </td>
        
        <td align="center"> 
            @genre.objTipoCliente.valor
        </td>
    </tr>
    }     
</table>

<br />
<div>
    Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount
     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<", "Index", new { page = 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })
        @Html.Raw(" ");
        @Html.ActionLink("< Prev", "Index", new { page = Model.PageNumber - 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })
    }
    else
    {
        @:<<
        @Html.Raw(" ");
        @:< Prev
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Next >", "Index", new { page = Model.PageNumber + 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })
        @Html.Raw(" ");
        @Html.ActionLink(">>", "Index", new { page = Model.PageCount, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })
    }
    else
    {
        @:Next >
        @Html.Raw(" ")
        @:>>
    }
</div>

</fieldset>
